package com.itheima.controller;

import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.pojo.SetmealGroupItemVO;
import com.itheima.service.SetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/setmeal")
@Api(tags = "套餐相关接口")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;

    /**
     * 套餐查询
     * @return
     */
    @PostMapping("/getSetmeal")
    @ApiOperation("套餐查询")
    public Result<List<Setmeal>> list () {
        log.info("套餐查询");
        List<Setmeal> setmeal = setmealService.list();
        return Result.success(setmeal);
    }

    /**
     * 根据套餐ID查询详情
     * @param id
     * @return
     */
    @PostMapping("/findById")
    @ApiOperation("根据套餐ID查询详情")
    public Result<Setmeal> bySetmealId (@RequestParam Integer id) {
        Setmeal setmeal = setmealService.getById(id);
        return Result.success(setmeal);
    }

}
